function concurRequest(urls, maxNum) {
  return new Promise((resolve) => {
    if (urls.length === 0) {
      resolve([]);
      return;
    }
    const results = [];
    let index = 0;
    for (let i = 0; i < Math.min(maxNum, urls.length); i++) {
      request();
    }
    let finallyNum = 0;
    //发送请求
    async function request() {
      if (index == urls.length) {
        return;
      }
      const i = index;
      const url = urls[index];
      index++;
      try {
        const resp = await fetch(url);
        results[i] = resp;
      } catch (error) {
        results[i] = err;
      } finally {
        finallyNum++;
        if (finallyNum === urls.length) {
          resolve(results);
        }
        request();
      }
    }
  });
}
